<template>
  <div>
    <div style="margin-bottom: 5px; margin-top: 0px">
      <el-button type="warning" size="small" @click="returnPreviousPage"
        >返回上一页</el-button
      >
    </div>
    <div id="container1">
      <div style="margin-top: 0px; margin-left: 20px">
        <el-divider></el-divider>
        <el-descriptions title="维修信息">
          <el-descriptions-item label="维修ID">{{
            fixDetail.fid
          }}</el-descriptions-item>
          <el-descriptions-item label="维修时间">{{
            fixDetail.fixTime
          }}</el-descriptions-item>
          <el-descriptions-item label="维修结果">{{
            fixDetail.softdel | filterSoftDel
          }}</el-descriptions-item>
          <el-descriptions-item label="维修人员">
            {{ fixDetail.tbWorker.uname }}
          </el-descriptions-item>
          <el-descriptions-item label="联系方式">{{
            fixDetail.tbWorker.idCard
          }}</el-descriptions-item>
        </el-descriptions>
      </div>
    </div>
    <div id="container2">
      <div style="margin-top: 0px; margin-left: 20px">
        <el-divider></el-divider>
        <el-descriptions title="故障信息">
          <el-descriptions-item label="故障ID">{{
            fixDetail.tbMalfunction.maid
          }}</el-descriptions-item>
          <el-descriptions-item label="故障类型">{{
            fixDetail.tbMalfunction.matype
          }}</el-descriptions-item>
          <el-descriptions-item label="故障详情">{{
            fixDetail.tbMalfunction.madesc
          }}</el-descriptions-item>
          <el-descriptions-item label="故障状态">
            {{
              fixDetail.tbMalfunction.declarantStatus | filterMalfunctionSoftDel
            }}
          </el-descriptions-item>
          <el-descriptions-item label="故障备案时间">{{
            fixDetail.tbMalfunction.declarantTime
          }}</el-descriptions-item>
          <el-descriptions-item label="故障申报人">{{
            fixDetail.tbMalfunction.declarantName
          }}</el-descriptions-item>
          <el-descriptions-item label="联系方式">{{
            fixDetail.tbMalfunction.declarantPhone
          }}</el-descriptions-item>
        </el-descriptions>

        <div style="margin-top: 0px; margin-left: 20px">
          <el-divider></el-divider>
          <el-descriptions title="床位信息">
            <el-descriptions-item label="医院编号">{{
              fixDetail.tbBed.hid
            }}</el-descriptions-item>
            <el-descriptions-item label="科室编号">{{
              fixDetail.tbBed.did
            }}</el-descriptions-item>
            <el-descriptions-item label="床位编号">{{
              fixDetail.tbBed.bnum
            }}</el-descriptions-item>
            <el-descriptions-item label="床位型号">{{
              fixDetail.tbBed.type
            }}</el-descriptions-item>
            <el-descriptions-item label="厂家地址">{{
              fixDetail.tbBed.manufacturerAddress
            }}</el-descriptions-item>
            <el-descriptions-item label="厂家电话">{{
              fixDetail.tbBed.manufacturerPhone
            }}</el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
    </div>
  </div>
</template>
<style scoped>
#container1 {
  width: 95%;
  height: 200px;
  margin: auto;
  border: #cfcccc solid 1px;
  background-color: white;
  text-align: center;
}
#container2 {
  width: 95%;
  height: 480px;
  margin: auto;
  margin-top: 30px;
  border: #cfcccc solid 1px;
  background-color: white;
  text-align: center;
}
</style>
<script>
import { getFixDetailByFid } from "@/api/fixDetail.js";
export default {
  data() {
    return {
      fid: 0,
      fixDetail: {},
    };
  },
  filters: {
    filterSoftDel(val) {
      //0已修复；1无法修复
      if (val == 0) {
        return "已修复";
      }
      if (val == 1) {
        return "无法修复";
      }
    },

    filterMalfunctionSoftDel(val) {
      //待维修、修复中、已修复、无法修复（0、1、2、3）
      if (val == 0) {
        return "待维修";
      }
      if (val == 1) {
        return "修复中";
      }
      if (val == 2) {
        return "已修复";
      }
      if (val == 3) {
        return "无法修复";
      }
    },
  },
  methods: {
    loadFixDetail() {
      getFixDetailByFid(this.fid).then((res) => {
        if (res.data.code == 200) {
          this.fixDetail = res.data.data;
        }
      });
    },
    returnPreviousPage(){
        this.$router.push("/Home/Fix");
    }
  },
  mounted() {
    this.fid = this.$route.query.fid;
    this.loadFixDetail();
  },
};
</script>